/*
 * ItemType.h
 *
 *  Created on: 24.03.2009
 *      Author: Konan Andrej
 */

#ifndef ITEMTYPE_H_
#define ITEMTYPE_H_

#include <QString>
#include <QVector>
#include <QDate>

#include "Defs.h"

class ItemType{
protected:
	//number of QString records in the item
	int n;
	QVector<QString> Fields;

public:
	//Constructor
	ItemType();
	ItemType( const int a_n );
	//Get & Set methods
	QString Get( const int i ) const;
	int Set( const int i, const QString& str );
        int GetFieldNumber() const { return n; }
};

class StockItem : public ItemType{
public:
	QString GetArticle() const { return Fields[0]; }
	void SetArticle( const QString& article ) { Fields[0] = article; }

	QString GetDescription() const { return Fields[1]; }
	void SetDescription( const QString& description ) { Fields[1] = description; }

	int GetNumber() const { return Fields[2].toInt(); }
	void SetNumber( const int number );

	QString GetFormat() const { return Fields[3]; }
	void SetFormat( const QString& format ) { Fields[3] = format; }

	StockItem( int a_n = 4 );
        //StockItem( const ItemType& item );
};

class OrderItem : public ItemType {
public:
        QDateTime GetDateTime() const { return QDateTime::fromString( Fields[0], "hh:mm:ss yyyy.MM.dd" ); }
        void SetDateTime( const QDateTime& date ) { Fields[0] = date.toString( "hh:mm:ss yyyy.MM.dd" ); }

        QString GetStatus() const { return Fields[1]; }
        void SetStatus( const QString& status ) { Fields[1] = status; }

        QString GetDescription() const { return Fields[2]; }
        void SetDescription( const QString& descr ) { Fields[2] = descr; }

        QString GetDatabase() const { return Fields[3]; }
        void SetDatabse( const QString& db ) { Fields[3] = db; }

        OrderItem( int a_n = 4 );
};

typedef OrderItem IncomeItem;
typedef OrderItem OperationItem;

#endif /* ITEMTYPE_H_ */
